﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Expect.Report.Word
{
    class HelpGenerator
    {
        public static void Generate()
        {
            WriteSampleCommand();
            Console.WriteLine(string.Empty); 
            Console.WriteLine("Arguments:");
            Console.WriteLine(string.Empty); 
            WriteArgument("source (required)", "Path to the assembly containing data");
            WriteArgument("template (required*)", "Path to the docx used as a template"); 
            WriteArgument("output (required*)", "Path to generated docx file");
            WriteArgument("headings (required*)", "Word styles used for headings, separated by semicolon");
            WriteArgument("specifications", "Name of word style used for specifications");
            WriteArgument("descriptions", "Name of word style used for descriptions");
            WriteArgument("tables", "Name of word style used for tables");
            WriteArgument("verbose", "Verbose output");

            Console.WriteLine(string.Empty); 
            Console.WriteLine("Except for the parameter \"source\", parameters could be provided within the app.config of the source file."+
                " The parameters provided in the command line have priority over the one in the config file");
        }

        private static void WriteSampleCommand()
        {
            Console.WriteLine(string.Empty); 
            Console.WriteLine("Sample command:"); 
            Console.WriteLine(string.Empty);
            Console.WriteLine("Expect.Report.Word.exe -source=[Path to assembly] -template=[Path to docx template] "+
                "-headings=[list of style names] -tables=[tables style name] -descriptions=[style name] "+
                "-output=[Path to docx output] -verbose=1");
            Console.WriteLine(string.Empty);
            
        }

        private static void WriteArgument(string argname, string description)
        {
            Console.WriteLine(Conform(argname, 22) + description);
        }

        private static string Conform(string s, int size)
        {
            StringBuilder sb = new StringBuilder(s);
            for (int i = s.Length; i < size; i++)
            {
                sb.Append(" ");
            }
            return sb.ToString();
        }
    }
}
